import { Col, Row } from 'antd';
import { connect } from 'umi';
import '../common/styles.less';
// import { ContractHomeView } from './HomeContract/mview/ContractHomeView';
// import { ContractWarnView } from './WarnContract/mview/ContractWarnView';
import { CommonFunctionView } from './CommonFunction/mview/CommonFunctionView';
import { ContractCountCollec } from './ContractCount';
import { ContractHomeContext } from '../common';
import ScrollBarLayoutNotScroll from '@/components/ScrollBarLayoutNotScroll';
import { ContractCountPayment } from './ContractCount/mview/ContractCountPayment';
import { useContractHPReducer } from '../common/useReducer';
import { ContractHomeTableView } from './HomeContract/mviewTable/ContractHomeTableView';

const ContractHomePage = ({ curRes }) => {
  const { dispatch, copeWithData, collectionData } = useContractHPReducer();

  // 样式
  const styleFixCls = 'contract-homepage-';
  return (
    <ContractHomeContext.Provider
      value={{
        curRes,
        styleFixCls,
        copeWithData,
        collectionData,
        dispatch,
      }}
    >
      <div className={styleFixCls + 'RootDiv'}>
        <ScrollBarLayoutNotScroll style={{ padding: 0 }}>
          <Row gutter={[8, 8]}>
            <Col span={16} className={styleFixCls + 'RootDiv-ColSpanA'}>
              <ContractHomeTableView curRes={curRes} />
            </Col>

            <Col span={8} className={styleFixCls + 'RootDiv-ColSpanA'}>
              <CommonFunctionView curRes={curRes} />
            </Col>

            {/* 合同收款统计 */}
            {(curRes?.['/contractReportController/all'] ||
              curRes?.['/contractReportController/companyID'] ||
              curRes?.['/contractReportController/departmentID'] ||
              curRes?.['/contractReportController/userID']) && <ContractCountPayment />}

            {/* 合同收款统计 */}
            {(curRes?.['/contractReportController/all'] ||
              curRes?.['/contractReportController/companyID'] ||
              curRes?.['/contractReportController/departmentID'] ||
              curRes?.['/contractReportController/userID']) && <ContractCountCollec />}
          </Row>
        </ScrollBarLayoutNotScroll>
      </div>
    </ContractHomeContext.Provider>
  );
};
// export default ContractHomePage
export default connect(({ baseLogin }: Record<string, any>) => ({
  curRes: baseLogin?.permissions,
}))(ContractHomePage);
